package com.ellricky.baselib.adapter.student

import android.widget.ImageView
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.adapter.SmartViewHolder
import com.bumptech.glide.Glide
import com.ellricky.baselib.R
import com.ellricky.baselib.entity.new.ClassStuRecord
import com.ellricky.baselib.util.GlideUtil

class StudentClassRecordAdapter(val courseType: String) :
    BaseRecyclerAdapter<ClassStuRecord>(R.layout.base_adapter_student_class_record) {

    override fun onBindViewHolder(holder: SmartViewHolder, data: ClassStuRecord, p2: Int) {
        val ivBg = holder.itemView.findViewById<ImageView>(R.id.iv_bg)
        holder.text(R.id.tv_course_type, courseType)
            .text(R.id.tv_course_name, data.courseware_name)
            .text(R.id.tv_desc, data.job_desc)
            .text(R.id.tv_time, data.time)
            .text(R.id.tv_teacher, "教师：${data.teacher_name}")

        if (data.job_image.isNotEmpty()) {
            Glide.with(holder.itemView.context).load(data.job_image).into(ivBg)
        } else {
            ivBg.setImageResource(R.drawable.base_icon_class_record)
        }

    }
}